﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Recognition;
using System.Threading;
using grounding.parser;

namespace grounding.tests.SpeechToTextTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // Disable Ctrl+C OS interruption
            Console.TreatControlCAsInput = true;

            // Setup SpeechToText
            SpeechToText stt = new SpeechToText();
            stt.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(stt_SpeechRecognized);
            stt.DebugMode = false;

            // Helpful text
            Console.WriteLine("Starting SpeechToTextTest...");
            Console.WriteLine("You should be able to dictate and have your dictation's textual representation printed out in this console window:");

            // Start recognition
            stt.Start();

            // Spin until escape key is pressed since recognition is asynchronous
            ConsoleKeyInfo key;
            do
            {
                key = Console.ReadKey(true);
            } while (key.Key != ConsoleKey.Escape && !(key.Key == ConsoleKey.C && key.Modifiers == ConsoleModifiers.Control));
        }

        static void stt_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            Console.WriteLine(e.Result.Text);
        }
    }
}
